<?php namespace Common\Model;
use Hdphp\Model\Model;
class OrderList extends Model{
	protected $table = 'orderlist';
/*//	注册信息的自动验证
	protected $validate = array(
		array('username','required','用户名不能为空',3,3),
		array('username','user:5,20','用户名不能少于5个且不能超过20个字符',3,3),
		array('password','required','密码不能为空',3,3),
		array('password','minlen:5','密码不能少于5位',3,3),
		array('password','regexp:/^[A-Za-z0-9_-]+$/is ','密码只能是数字，字母，下划线',3,3),
		array('password2','required','验证密码不能为空',3,3),
		array('password2','minlen:5','密码不能少于5位',3,3),
		array('email','required','邮箱不能为空',3,3),
		array('email','email','输入的邮箱不正确',3,3)
	);
//	自动完成注册时间
	protected $auto = array(
		array('regtime','time','function',3,1)
	);
	*/
//	用户注册
	public function store($oid){
		$orderData = Q('post.');
//		定义一个空数组保存订单数组
		$data = array();
		$goodsModel = new \Common\Model\Goods;
//		组合订单列表数据
		foreach ($orderData['gid'] as $k => $v) {
			$temp = array();
			$temp['orders_oid'] = intval($oid);
			$temp['goods_gid'] = intval($v);
			$temp['number'] = intval($orderData['num'][$k]);
			$temp['subtotal'] = $temp['number'] * $goodsModel->where("gid = {$v}")->pluck('sprice');
			$data[] = $temp;
		}
//		保存订单列表数据
		foreach ($data as $v) {
			$this->add($v);
		}
		return true;
	}

}
 ?>